import { devDebug } from '../../utils/settings'

Page({
  data: {
    stadiumInfo: null,
    imgList: ['/images/stadium1.jpeg', '/images/stadium1.jpeg', '/images/stadium1.jpeg'],
    act: 0,
  },
  onLoad(options) {
    try {
      this.setData({ stadiumInfo: JSON.parse(options.stadiumInfo) });
    } catch (e) {
      wx.showToast({
        title: '参数解析错误，请刷新',
        icon: 'none'
      })
    }
    if (devDebug) console.log(this.data.stadiumInfo);
  },
  onCallPhone() {
    wx.makePhoneCall({
      phoneNumber: this.data.stadiumInfo.stadium_phone,
    })
  },
  onOpenLocation() {
    const geo = this.data.stadiumInfo.stadium_geo;
    wx.openLocation({
      latitude: geo.latitude,
      longitude: geo.longitude,
      scale: 18
    })
  },
  onChangeTab({ detail }) {
    this.setData({ act: detail.index })
  },
})